package service.impl.security;

import java.util.List;

import service.impl.BaseDataServiceImpl;
import service.interf.security.IGroup;
import dao.interf.IGroupMemberDAO;
import dao.pojo.Group;
import dao.pojo.GroupMember;

public class GroupImpl extends BaseDataServiceImpl implements IGroup {
	private IGroupMemberDAO gmDao;
	
	public void setGmDao(IGroupMemberDAO gmDao) {
		this.gmDao = gmDao;
	}

	/**
	 * 获取用户组信息
	 * @param userId: 用户id
	 * @return 组名
	 */
	public String findUserGroups4Login(Long userId){
		List<GroupMember> gmLst = gmDao.findByProperties(new String[]{"user.userId"}, new Object[]{userId});
		if(null != gmLst){
			for(GroupMember gm:gmLst){
				Group g = gm.getGroup();
				if(null != g){
					String x = "";
					x += g.getGroupName();
					return x;
				}
			}
		}
		return null;
	}
}
